/*
 * @Description: 日志 - 格式转换
 * @Author: Rfan
 * @Date: 2022-09-20 15:34:08
 * @LastEditTime: 2023-01-19 10:51:41
 */

import { Key } from 'react';
import { logRequest } from '@/utils/request';
import { ICommonParams, ICoordinate, IPageQuery } from '@/interfaces/global';

// 列表请求参数
export interface IQueryConvertLog {
  createTime?: string;
  id?: number;
  logType?: number;
  operator?: number;
  operatorName?: string;
  operatorTime?: string;
}

// 日志内容
export interface ILogContent {
  commonParams: ICommonParams;
  coordinate: ICoordinate;
  fileName: string;
  fmtSourceUrl: string;
  fmtSource: string;
  fmtTarget: string;
  version: number;
  entryId: number;
  errorMsg: null;
  status: number;
}
// 列表返回数据
export interface IConvertLogRes {
  logType: number;
  createTime: number;
  logContent: ILogContent;
  operatorTime: number;
  archiveTypeName: string;
  id: number;
  fondName: string;
  operatorName: string;
  operator: number;
}

// 分页查询列表
export function fetchConvertLogListByPage(data: IPageQuery<IQueryConvertLog>) {
  return logRequest({
    url: `/format-convert-log/page`,
    method: 'post',
    data
  });
}

// 删除日志
export function deleteConvertLog(id: Key) {
  return logRequest({
    url: `/format-convert-log/${id}`,
    method: 'delete'
  });
}

// 日志导出
export function exportConvertLog(data: any[]) {
  return logRequest({
    url: `/format-convert-log/export`,
    method: 'post',
    data,
    responseType: 'arraybuffer'
  });
}
